<template>
    <Row>
        <Card>
            <Row>
                <Form class="form-row" ref="search" :model="params" :label-width="90" inline>
                    <FormItem label="停车场" prop="parking-name">
                        <div class="filters-input">
                        <Input type="text" v-model="params.parking" placeholder="请输入停车场名称" class="normal-input"/>
                        </div>
                    </FormItem>
                    <FormItem>
                        <Button type="primary" @click="handleSearch">搜索</Button>
                    </FormItem>
                </Form>
            </Row>
            <Row class="form-row">
                <Button type="primary" icon="md-add" @click="saveParkingBaseInfoModal = true;modalType = 'add';parkingBaseInfo={}">新增</Button>
            </Row>

            <el-table :data="data.list" border stripe style="width: 100%">
                <template slot="empty">暂无数据</template>
                <el-table-column prop="parkingName" label="停车场名称"></el-table-column>
                <el-table-column prop="housingName" label="小区"></el-table-column>
                <el-table-column prop="totalSpace" label="总车位数"></el-table-column>
                <el-table-column prop="restSpace" label="剩余车位数"></el-table-column>
                <el-table-column label="操作" width="150" align="center">
                    <template slot-scope="scope">
                        <el-dropdown>
                            <el-button type="primary">
                                操作<i class="el-icon-arrow-down el-icon--right"></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown" align="center">
                                <el-dropdown-item @click.native="editButton(scope.row)">修改</el-dropdown-item>
                                <el-dropdown-item @click.native="inButton(scope.row)">车辆入场</el-dropdown-item>
                                <el-dropdown-item @click.native="outButton(scope.row)">车辆出场</el-dropdown-item>
                                <el-dropdown-item @click.native="payButton(scope.row)">支付配置</el-dropdown-item>
                                <el-dropdown-item @click.native="ruleButton(scope.row)">收费规则</el-dropdown-item>
                                <el-dropdown-item @click.native="adminButton(scope.row)">账号管理</el-dropdown-item>
                                <el-dropdown-item @click.native="downloadButton(scope.row)">物料下载</el-dropdown-item>
                                <!--<el-dropdown-item @click.native="deleteButton(scope.row)">删除</el-dropdown-item>-->
                            </el-dropdown-menu>
                        </el-dropdown>
                    </template>
                </el-table-column>
            </el-table>
            <Page style="margin: 10px 0;" :total="data.total" :current="data.pageNum" :page-size="data.pageSize" show-total show-sizer show-elevator @on-change="handlePage" @on-page-size-change='handlePageSize'>
            </Page>
        </Card>
        <Modal
            v-model="saveParkingBaseInfoModal"
            :mask-closable="false"
            :closable="false"
            width="650"
            :title="modalType == 'add' ? '新增': '修改'">
            <Form ref="parkingBaseInfoForm" :model="parkingBaseInfo" :rules="parkingBaseInfoValidateRules" :label-width="90">
                <FormItem label="小区" prop="housingName">
                    <Select v-model="parkingBaseInfo.housingId" placeholder="请选择小区" class="normal-input" :clearable="true">
                        <Option v-for="item in communityList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                </FormItem>
                <FormItem label="停车场名称" prop="parkingName">
                    <Input v-model="parkingBaseInfo.parkingName" placeholder="停车场名称" ></Input>
                </FormItem>
                <FormItem label="总车位数" prop="totalSpace">
                    <InputNumber v-model="parkingBaseInfo.totalSpace" placeholder="总车位数" class="max-width-input"></InputNumber>
                </FormItem>
                <FormItem label="剩余车位数" prop="restSpace">
                    <InputNumber v-model="parkingBaseInfo.restSpace" placeholder="剩余车位数" class="max-width-input"></InputNumber>
                </FormItem>
                <FormItem label="免费停留时间" prop="freeTime">
                    <InputNumber v-model="parkingBaseInfo.freeTime" placeholder="免费停留时间（分钟）" class="max-width-input"></InputNumber>
                </FormItem>
                <FormItem label="停车场位置" prop="parkingAddress">
                    <Input v-model="parkingBaseInfo.parkingAddress" placeholder="停车场位置" ></Input>
                </FormItem>
                <FormItem label="联系电话" prop="parkingMobile">
                    <Input v-model="parkingBaseInfo.parkingMobile" placeholder="停车场联系电话" ></Input>
                </FormItem>
                <FormItem label="停车场类型" prop="parkingLotType">
                    <Select v-model="parkingBaseInfo.parkingLotType" placeholder="请选择停车场类型"  :clearable="true">
                        <Option v-for="item in parkingType" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="onCancel()">关闭</Button>
                <Button type="primary" size="large" @click="handleSaveParkingSubmit" :loading="saveParkingBaseInfoLoading">确定</Button>
            </div>
        </Modal>
        <Modal
            v-model="saveParkingPayInfoModal"
            :mask-closable="false"
            :closable="false"
            width="650"
            title="配置支付信息">
            <Form ref="parkingPayInfoForm" :model="parkingPayInfo" :rules="parkingPayInfoValidateRules" :label-width="160">
                <!--<FormItem label="小区" prop="housingName">-->
                    <!--<Select v-model="parkingPayInfo.housingId" placeholder="请选择小区" class="normal-input">-->
                        <!--<Option v-for="item in communityList" :value="item.id" :key="item.id">{{ item.name }}</Option>-->
                    <!--</Select>-->
                <!--</FormItem>-->
                <FormItem label="支付后最大停留时间" prop="leaveMaxtime">
                    <InputNumber v-model="parkingPayInfo.leaveMaxtime" placeholder="支付后最大停留时间(单位分钟)" class="normal-input"></InputNumber>
                </FormItem>
                <FormItem label="支付宝服务商ID" prop="alipayAgentId">
                    <Input v-model="parkingPayInfo.alipayAgentId" placeholder="支付宝服务商ID" class="normal-input"></Input>
                </FormItem>
                <FormItem label="支付宝收款方ID" prop="alipayMchntId">
                    <Input v-model="parkingPayInfo.alipayMchntId" placeholder="支付宝收款方ID" class="normal-input"></Input>
                </FormItem>
                <FormItem label="支付宝授权token" prop="alipayAppAuthToken">
                    <Input v-model="parkingPayInfo.alipayAppAuthToken" placeholder="支付宝授权token" class="normal-input"></Input>
                </FormItem>
                <FormItem label="是否开启支付宝无感停车" prop="alipayIsEnable">
                    <RadioGroup v-model="parkingPayInfo.alipayIsEnable">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>

                <FormItem label="微信支付子商户APPID" prop="wxpaySubAppid">
                    <Input v-model="parkingPayInfo.wxpaySubAppid" placeholder="微信支付子商户APPID" class="normal-input"></Input>
                </FormItem>
                <FormItem label="微信支付子商户ID" prop="wxpaySubMchId">
                    <Input v-model="parkingPayInfo.wxpaySubMchId" placeholder="微信支付子商户ID" class="normal-input"></Input>
                </FormItem>
                <FormItem label="是否开启微信支付无感停车" prop="wxpayIsEnable">
                    <RadioGroup v-model="parkingPayInfo.wxpayIsEnable">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>
                <FormItem label="微信云支付门店账号" prop="outShopId">
                    <Input v-model="parkingPayInfo.outShopId" placeholder="微信云支付门店账号" class="normal-input"></Input>
                </FormItem>
                <FormItem label="微信云支付订单前缀" prop="outShopTradePre">
                    <Input v-model="parkingPayInfo.outShopTradePre" placeholder="微信云支付订单前缀" class="normal-input"></Input>
                </FormItem>
                <FormItem label="易联云打印机终端号" prop="ylyTerminalNumber">
                    <Input v-model="parkingPayInfo.ylyTerminalNumber" placeholder="易联云打印机终端号" class="normal-input"></Input>
                </FormItem>
                <FormItem label="易联云打印机秘钥" prop="ylySecretKey">
                    <Input v-model="parkingPayInfo.ylySecretKey" placeholder="易联云打印机秘钥" class="normal-input"></Input>
                </FormItem>
                <FormItem label="收费说明" prop="parkingFeeDescription">
                    <Input v-model="parkingPayInfo.parkingFeeDescription" placeholder="收费说明" class="normal-input"></Input>
                </FormItem>
                <FormItem label="是否开启停车场数据同步" prop="notifyIsEnable">
                    <RadioGroup v-model="parkingPayInfo.notifyIsEnable">
                        <Radio label="1">开启</Radio>
                        <Radio label="0">关闭</Radio>
                    </RadioGroup>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="onCancel()">关闭</Button>
                <Button type="primary" size="large" @click="handleSaveParkingPayInfoSubmit" :loading="saveParkingPayInfoLoading">确定</Button>
            </div>
        </Modal>
        <Modal
            v-model="setRateModal"
            width="820"
            title="收费规则">
            <Form ref="rateBaseInfo" :model="rateBaseInfo" :rules="parkingRateInfoValidateRules" :label-width="110">
                <FormItem label="计费方式" prop="feeMode">
                    <RadioGroup v-model="rateBaseInfo.feeMode">
                        <Radio label="1">循环计费</Radio>
                        <Radio label="2">分时段计费</Radio>
                    </RadioGroup>
                </FormItem>
                <Row v-if="rateBaseInfo.feeMode == 1">
                    <FormItem label="免费时长" prop="freeTime">
                        <Input v-model="rateBaseInfo.freeTime" placeholder="入场超过此时间后开始计费（单位：分钟）" ></Input>
                        <p>单位：分钟</p>
                    </FormItem>
                    <FormItem label="循环周期时长" prop="noslotTimeLimit">
                        <Input v-model="rateBaseInfo.noslotCycleTime" placeholder="循环周期（单位：分钟）" ></Input>
                        <p>单位：分钟</p>
                    </FormItem>
                    <FormItem label="周期内收费封顶" prop="noslotMoneyLimit">
                        <Input v-model="rateBaseInfo.noslotMoneyLimit" placeholder="周期内收费封顶（单位：元）"></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="单次计费周期" prop="noslotTime">
                        <Input v-model="rateBaseInfo.noslotTime" placeholder="每多少分钟计算一次费用"></Input>
                        <p>每多少分钟计算一次费用</p>
                    </FormItem>
                    <FormItem label="单次计费金额" prop="noslotMoney">
                        <Input v-model="rateBaseInfo.noslotMoney" placeholder="单次计费周期内收费多少元"></Input>
                        <p>单次计费周期内收费多少元</p>
                    </FormItem>
                    <FormItem label="一次性收费" prop="noslotRuleMoney">
                        <Input v-model="rateBaseInfo.oneTimeMoney" placeholder="一次性收费（单位：元）"></Input>
                        <p>单位：元</p>
                    </FormItem>
                </Row>
                <Row v-if="rateBaseInfo.feeMode == 2">
                    <FormItem label="选择时间段">
                        <Row>
                            <Col span="11">
                                <TimePicker type="time" placeholder="开始时间" v-model="rateBaseInfo.slotStartTime" ></TimePicker>
                            </Col>
                            <Col span="2" style="text-align: center">-</Col>
                            <Col span="11">
                                <TimePicker type="time" placeholder="结束时间" v-model="rateBaseInfo.slotEndTime"></TimePicker>
                            </Col>
                        </Row>
                    </FormItem>
                    <FormItem label="免费时长" prop="freeTime">
                        <Input v-model="rateBaseInfo.freeTime" placeholder="入场超过此时间后开始计费（单位：分钟）"></Input>
                        <p>入场超过此时间后开始计费（单位：分钟）</p>
                    </FormItem>
                    <FormItem label="段内首次计费时间" prop="slotCycleFirstTime">
                        <Input v-model="rateBaseInfo.slotCycleFirstTime" placeholder="段内首次计费时间（分钟）" ></Input>
                        <p>单位：分钟</p>
                    </FormItem>
                    <FormItem label="段内首次计费金额" prop="slotCycleFirstMoney">
                        <Input v-model="rateBaseInfo.slotCycleFirstMoney" placeholder="段内首次计费金额（元）" ></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="段内单次计费周期" prop="slotCycleinTime">
                        <Input v-model="rateBaseInfo.slotCycleInTime" placeholder="段内单次计费周期（分钟）" ></Input>
                        <p>单位：分钟</p>
                    </FormItem>
                    <FormItem label="段内单次计费金额" prop="slotCycleinMoney">
                        <Input v-model="rateBaseInfo.slotCycleInMoney" placeholder="段内单次计费金额（元）" ></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="段内收费封顶" prop="slotMoneylimit">
                        <Input v-model="rateBaseInfo.slotCycleInMoneyLimit" placeholder="段内收费封顶（元））" ></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="段外单次计费周期" prop="slotCycleoutTime">
                        <Input v-model="rateBaseInfo.slotCycleOutTime" placeholder="每多少分钟计算一次费用"></Input>
                        <p>单位：分钟</p>
                    </FormItem>
                    <FormItem label="段外单次计费金额" prop="slotCycleoutMoney">
                        <Input v-model="rateBaseInfo.slotCycleOutMoney" placeholder="单次计费周期内收费多少元" ></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="段外收费封顶" prop="slotCycleoutMoneylimit">
                        <Input v-model="rateBaseInfo.slotCycleOutMoneyLimit" placeholder="段外收费封顶（元）" ></Input>
                        <p>单位：元</p>
                    </FormItem>
                    <FormItem label="24小时收费封顶" prop="slotDayMoney">
                        <Input v-model="rateBaseInfo.slotDayMoney" placeholder="24小时收费封顶（元）"></Input>
                        <p>单位：元</p>
                    </FormItem>
                </Row>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="onCancel()">关闭</Button>
                <Button type="primary" size="large" @click="handleSetRateSubmit" :loading="saveParkingBaseInfoLoading">确定</Button>
            </div>
        </Modal>
        <Modal
            v-model="saveParkingAdmin"
            :mask-closable="false"
            :closable="false"
            title="设置停车场管理员">
            <Form ref="saveParkingAdminForm" :label-width="90">
                <FormItem label="管理员" prop="housingName">
                    <Select v-model="parkingAdmin" multiple placeholder="请选择管理员" class="normal-input" :clearable="true">
                        <Option v-for="item in sysUserList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="onCancel()">关闭</Button>
                <Button type="primary" size="large" @click="handleSaveParkingAdminSubmit" :loading="saveParkingAdminLoading">确定</Button>
            </div>
        </Modal>
        <Modal v-model="formVisible" title="车辆入场" width="680">
            <Form ref="saveHousing"  :label-width="110">
                <FormItem label="路口" prop="roadName">
                    <div class="filters-input">
                        <el-select v-model="inData.in_road_id" :clearable="true" placeholder="请选择出入口"
                                   class="normal-input" no-data-text="暂无数据">
                            <el-option v-for="item in roadData" :value="item.id" :key="item.id" :label="item.roadName">
                            </el-option>
                        </el-select>
                    </div>
                </FormItem>
                <FormItem label="车牌号码" prop="plate_number">
                    <Input v-model="inData.plate_number" placeholder="车牌号码"></Input>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="onCancel()">关闭</Button>
                <Button type="primary" size="large" @click="handleSubmit" :loading="tableLoading">确定</Button>
            </div>
        </Modal>

    </Row>

</template>

<script>
    import baseURL from '_conf/url'
    export default {
        data () {
            return {
                params : {},
                data: {
                    pageNum: 1,
                    pageSize: 10,
                    pageTotal: 0
                },
                parkingRateInfoValidateRules: {},
                parkingBaseInfoValidateRules: {
                    housingId: [
                        { required: true, message: "请选择小区", trigger: "blur"}
                    ],
                    parkingName: [
                        { required: true, message: "请输入停车场名称", trigger: "blur"}
                    ],
                    // totalSpace: [
                    //     { required: true, message: "请输入总车位数", trigger: "blur"}
                    // ],
                    parkingAddress: [
                        { required: true, message: "请输入停车场位置", trigger: "blur"}
                    ],
                    // parkingLotType: [
                    //     { required: true, message: "请选择停车场类型", trigger: "blur"}
                    // ],
                },
                parkingBaseInfo: {},
                saveParkingBaseInfoLoading: false,
                saveParkingBaseInfoModal: false,
                parkingPayInfoValidateRules: {},
                modalType: "add",
                saveParkingPayInfoModal: false,
                saveParkingPayInfoLoading: false,
                parkingPayInfo: {},
                setRateModal: false,
                saveRateLoading: false,
                formVisible:false,
                rateBaseInfo: {
                    feeMode: '1'
                },
                // parkingData: [],
                communityList: [],
                roadData:[],
                inData:{},
                parkingType: [
                    {
                        "id": '1',
                        "name": "居民小区"
                    },
                    {
                        "id": '2',
                        "name": "商圈停车场（购物中心商业广场商场等）"
                    },
                    {
                        "id": '3',
                        "name": "路侧停车"
                    },
                    {
                        "id": '4',
                        "name": "公园景点（景点乐园公园老街古镇等）"
                    },
                    {
                        "id": '5',
                        "name": "商务楼宇（酒店写字楼商务楼园区等）"
                    },
                    {
                        "id": '6',
                        "name": "其他"
                    },
                    {
                        "id": '7',
                        "name": "交通枢纽（机场火车站汽车站码头港口等）"
                    },
                    {
                        "id": '8',
                        "name": "市政设施（体育场博物图书馆医院学校等）"
                    }
                ],
                sysUserList: [],
                parkingAdmin: [],
                saveParkingAdminLoading: false,
                saveParkingAdmin: false,
                tableLoading: false
            }
        },
        created: function () {
            this.init()
        },
        methods: {
            getCommunityList: function () {
                let url = "/api/housing/getHousingByLogin";
                this.postRequest(url).then(res => {
                    console.log(res);
                    if (res) {
                        this.communityList = res;
                    }
                });
            },
            init: function() {
                this.loadData();
                this.getCommunityList();
            },
            handleSearch: function () {
                this.loadData()
            },
            loadData: function () {
                let url = "/api/parking/list?page_num=" + this.data.pageNum + "&page_size=" + this.data.pageSize
                if (this.params.parking) {
                    url = url +  '&search_text=' + this.params.parking
                }
                this.getRequest(url).then(resp => {
                    console.log(resp)
                    if (resp.code == 20000) {
                        this.data = resp.data;
                        return
                    }
                    this.$Message.error(resp.message);
                })
            },
            getRateInfo: function (parkingId) {
                const url = "/api/parking/rate/info?parking_id=" + parkingId
                this.getRequest(url).then(resp => {
                    if (resp.code == 20000) {
                        if (resp.data != null) {
                            resp.data.feeMode = new String(resp.data.feeMode).toString()
                            console.log(resp)
                            this.rateBaseInfo = resp.data
                        } else {
                            this.rateBaseInfo = {feeMode: '1', parkingId}
                        }
                        return
                    }
                    this.$Message.error(resp.message);
                })
            },
            saveParking: function (params) {
                let url = "/api/parking/base/info"
                this.postRequest(url, params).then(resp => {
                    console.log(resp)
                    this.saveParkingBaseInfoLoading = false
                    this.saveParkingPayInfoLoading = false
                    if (resp.code == 20000) {
                        this.saveParkingBaseInfoModal = false
                        this.saveParkingPayInfoModal = false
                        this.$Message.success("成功")
                        this.loadData()
                        return
                    }
                    this.$Message.error(resp.message);
                })
            },
            saveRateInfo: function (data) {
              const url = "/api/parking/rate/info"
              this.postRequest(url, data).then(resp => {
                  this.saveRateLoading = false
                  if (resp.code == 20000) {
                      this.setRateModal = false
                      this.$Message.success("成功")
                      return
                  }
                  this.$Message.error(resp.message);
              })
            },
            getSysUserList: function (parkingId) {
                const url = "/api/parking/sysuser/list/" +  parkingId
                this.getRequest(url).then(resp => {
                    console.log(resp)
                    if (resp.code == 20000) {
                        this.sysUserList = resp.data
                        return
                    }
                    this.$Message.error(resp.message);
                })
            },
            getParkingAdminList: function (parkingId) {
                const url = "/api/parking/admin/list/" +  parkingId
                this.getRequest(url).then(resp => {
                    console.log(resp)
                    if (resp.code == 20000) {
                        this.parkingAdmin = resp.data
                        return
                    }
                    this.$Message.error(resp.message);
                })
            },
            saveParkingAdminInfo: function () {
                const url = "/api/parking/admin/save"
                const data = {
                    parking_id: this.parkingBaseInfo.id,
                    user_ids: this.parkingAdmin
                }
                this.postRequest(url, data).then(resp => {
                    console.log(resp)
                    this.saveParkingAdminLoading = false
                    if (resp.code == 20000) {
                        this.saveParkingAdmin = false
                    }
                })
            },
            //按钮-修改 editButton
            editButton: function(row){
                this.saveParkingBaseInfoModal = true
                this.modalType = 'edit'
                this.parkingBaseInfo = row
            },
            //按钮-支付配置 payButton
            payButton: function(row){
                this.saveParkingPayInfoModal = true
                row.alipayIsEnable = new String(row.alipayIsEnable).toString()
                row.wxpayIsEnable = new String(row.wxpayIsEnable).toString()
                row.notifyIsEnable = new String(row.notifyIsEnable).toString()
                this.parkingPayInfo = row
            },
            //按钮-收费规则 ruleButton
            ruleButton: function(row){
                this.setRateModal = true
                this.getRateInfo(row.id)
            },
            //按钮-账号管理 adminButton
            adminButton: function(row){
                this.parkingBaseInfo = row
                this.saveParkingAdmin = true
                this.parkingAdmin = []
                this.getSysUserList(row.id)
                this.getParkingAdminList(row.id)
            },
            //按钮-物料下载 downloadButton
            downloadButton: function(row){
                location.href= baseURL + '/api/parking/material/download/' + row.id
            },
            //按钮-删除 deleteButton
            deleteButton: function(row){
                this.$Modal.confirm({
                    title: '提示',
                    content: '确定删除此停车场信息？',
                    onOk: () => {
                        this.$Message.info('Clicked ok');
                    },
                    onCancel: () => {
                        // this.$Message.info('Clicked cancel');
                    }
                });
            },
            handleSaveParkingSubmit: function () {
                this.$refs['parkingBaseInfoForm'].validate(valid => {
                    if (valid) {
                        this.saveParkingBaseInfoLoading = true
                        this.saveParking(this.parkingBaseInfo)
                    }
                })

            },
            handleSaveParkingPayInfoSubmit: function () {
                this.$refs['parkingPayInfoForm'].validate(valid => {
                    if (valid) {
                        this.saveParkingPayInfoLoading = true
                        this.saveParking(this.parkingPayInfo)
                    }
                })

            },
            handleSetRateSubmit: function () {
                console.log("handleUpdateRule")
                this.saveRateInfo(this.rateBaseInfo)

            },
            onCancel: function () {
                this.saveParkingBaseInfoModal = false
                this.saveParkingBaseInfoLoading = false
                this.saveParkingPayInfoLoading = false
                this.saveParkingPayInfoModal = false
                this.setRateModal = false
                this.saveRateLoading = false
                this.saveParkingAdmin = false
                this.saveParkingAdminLoading = false
                this.formVisible = false
            },
            handlePage(value) {
                this.data.pageNum = value;
                this.loadData();
            },
            handlePageSize(value) {
                this.data.pageSize = value;
                this.loadData();
            },
            handleSaveParkingAdminSubmit: function () {
                console.log(this.parkingAdmin)
                this.saveParkingAdminInfo()

            },
            inButton:function(row){
                console.log(row)
                this.getRequest("/api/parking/road?parkingId="+row.id+"&type=入口").then(res => {
                    this.tableLoading = false
                    if (res.code == 20000) {
                        this.formVisible = true;
                        this.roadData = res.data;
                        return
                    }
                    this.$Message.error(res.message)
                })

            },
            outButton:function(row){
                this.getRequest("/api/parking/road?parkingId="+row.id+"&type=出口").then(res => {
                    this.tableLoading = false
                    if (res.code == 20000) {
                        this.formVisible = true;
                        this.roadData = res.data;
                        return
                    }
                    this.$Message.error(res.message)
                })
            },
            //车辆入场
            handleSubmit: function () {
                const postParams={"AlarmInfoPlate" : {"channel" : 0,"deviceName" : "IVS","ipaddr" : "",
                        "result" : {"PlateResult" : {"bright" : 0,"carBright" : 0,"carColor" : 0,"colorType" : 1,"colorValue" : 0,"confidence" : 7,"direction" : 4,"gioouts" : [],"imagePath" : "","isoffline" : 0,"license" : "","location" : {"RECT" : {"bottom" : 838,"left" : 807,"right" : 1078,"top" : 779}},"plateid" : 140889,"timeStamp" : {"Timeval" : {"decday" : 10,"dechour" : 10,"decmin" : 27,"decmon" : 12,"decsec" : 12,"decyear" : 2018,"sec" : 1544408832,"usec" : 883767}},"timeUsed" : 239,"triggerType" : 8,"type" : 1}},"serialno" : "054b9792-9baec9d9","user_data" : ""}};

                if(this.inData.in_road_id == null || this.inData.in_road_id == ""){
                    this.$Message.error("请选择路口")
                    return;
                }
                if(this.inData.plate_number == null || this.inData.plate_number == ""){
                    this.$Message.error("请输入车牌号")
                    return;
                }
                for(var i=0;i<this.roadData.length ;i++){
                    if(this.roadData[i].id == this.inData.in_road_id){
                        const now = this.roadData[i];
                        postParams.AlarmInfoPlate.ipaddr = now.mainVideoIp;
                        postParams.AlarmInfoPlate.serialno = now.cameraId;
                        postParams.AlarmInfoPlate.result.PlateResult.license = this.inData.plate_number;
                        this.postU("http://parking.alipayjf.com/zhenshi/camera",postParams).then(res => {
                            this.inData={};
                            this.formVisible  = false;
                            this.loadData();
                            this.$Message.success("操作成功")
                        }).catch(
                        );
                    }
                }
            },
        }
    }
</script>
<style scoped>
    .max-width-input {
        width: 100%;
    }
</style>
